/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package braipetro.data_access;

import java.util.Dictionary;
import java.util.Enumeration;
import java.util.Hashtable;

/**
 *
 * @author manasses.lima
 */

public class DataRow {
    
    private Dictionary<String, String> values = new Hashtable();
    private Dictionary<String, String> oldValues = new Hashtable();
    private DataRowState state;
    
    
//------------------------------------------------------------------------------
// Constructors
//------------------------------------------------------------------------------

    public DataRow() {}

//------------------------------------------------------------------------------
// Gets and Setters
//------------------------------------------------------------------------------
    public DataRowState getState() {
        return state;
    }
    
    public void setState(DataRowState state) {
        this.state = state;
    }

    
//------------------------------------------------------------------------------
// Public Methods
//------------------------------------------------------------------------------
    public String get(String column) {
        return values.get(column);
    }
    
    public void addColumn(String columnName) {
        values.put(columnName, "");
    }
    
    public void setValue(String col, String value) {
        values.put(col, value);
    }  

    public void saveValues() {
        Enumeration enu = values.keys();
        
        while (enu.hasMoreElements()) {
            Object obj = enu.nextElement();
            oldValues.put((String)obj, values.get(obj));
        }
    }
    
    public void restoreValues() {
        Enumeration enu = oldValues.keys();
        
        while (enu.hasMoreElements()) {
            Object obj = enu.nextElement();
            values.put((String)obj, oldValues.get(obj));
        }
    }
    
    public void delete() {
        state = DataRowState.dsDELETED;
    }
    
//------------------------------------------------------------------------------
// Private Methods
//------------------------------------------------------------------------------

    
    
}    